Openspeech Encoder Decoder Model

Openspeech Encoder Decoder Model

class openspeech.models.openspeech_encoder_decoder_model.OpenspeechEncoderDecoderModel(configs: omegaconf.dictconfig.DictConfig, tokenizer: openspeech.tokenizers.tokenizer.Tokenizer)[source]

Base class for OpenSpeech’s encoder-decoder models.

Parameters
  • configs (DictConfig) – configuration set.

  • tokenizer (Tokenizer) – tokenizer is in charge of preparing the inputs for a model.

Inputs:
  • inputs (torch.FloatTensor): A input sequence passed to encoders. Typically for inputs this will be a padded FloatTensor of size (batch, seq_length, dimension).

  • input_lengths (torch.LongTensor): The length of input tensor. (batch)

Returns

Result of model predictions that contains predictions, logits, encoder_outputs,

encoder_logits, encoder_output_lengths.

Return type

outputs (dict)

forward(inputs: torch.Tensor, input_lengths: torch.Tensor) → Dict[str, torch.Tensor][source]

Forward propagate a inputs and targets pair for inference.

Inputs:

inputs (torch.FloatTensor): A input sequence passed to encoders. Typically for inputs this will be a padded FloatTensor of size (batch, seq_length, dimension). input_lengths (torch.LongTensor): The length of input tensor. (batch)

Returns

Result of model predictions that contains predictions, logits, encoder_outputs,

encoder_logits, encoder_output_lengths.

Return type

outputs (dict)

test_step(batch: tuple, batch_idx: int)collections.OrderedDict[source]

Forward propagate a inputs and targets pair for test.

Inputs:

train_batch (tuple): A train batch contains inputs, targets, input_lengths, target_lengths batch_idx (int): The index of batch

Returns

loss for training

Return type

loss (torch.Tensor)

training_step(batch: tuple, batch_idx: int)collections.OrderedDict[source]

Forward propagate a inputs and targets pair for training.

Inputs:

train_batch (tuple): A train batch contains inputs, targets, input_lengths, target_lengths batch_idx (int): The index of batch

Returns

loss for training

Return type

loss (torch.Tensor)

validation_step(batch: tuple, batch_idx: int)collections.OrderedDict[source]

Forward propagate a inputs and targets pair for validation.

Inputs:

train_batch (tuple): A train batch contains inputs, targets, input_lengths, target_lengths batch_idx (int): The index of batch

Returns

loss for training

Return type

loss (torch.Tensor)